package dp;

public class dp377 {
    public static void main(String[] args) {
        System.out.println(combinationSum4(new int[]{1,2,3}, 4));
    }
    public static int combinationSum4(int[] nums, int target) {
        //完全背包问题，排列问题
        int[] dp = new int[target + 1];
        dp[0] = 1;
        for (int j = 0; j <= target; j++){
            for (int i = 0; i < nums.length; i++) {
                if(nums[i] <= j)
                    dp[j] += dp[j - nums[i]];
            }
        }
        return dp[target];
    }
}
